package com.example.dakotanews.dto;

import com.example.dakotanews.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PersonalInfoDTO {

    private Integer id;
    private String name;
    private String avatar;
    private String cover;
    private String headline;
    private int gender;
    private boolean followedIf;
    // 用户统计信息
    private HashMap<String, Object> stats = new HashMap<>();

    // 为统计信息赋值
    public void putArticles(int value) {
        stats.put("articles", value);
    }
    public void putBeLikes(int value) {
        stats.put("beLikes", value);
    }
    public void putBeCollections(int value) {
        stats.put("beCollections", value);
    }
    public void putFollowers(int value) {
        stats.put("followers", value);
    }
    public void putFollowing(int value) {
        stats.put("following", value);
    }
    public void putLikeIssues(int value) {
        stats.put("likeIssues", value);
    }
    public void putLikeSections(int value) {
        stats.put("likeSections", value);
    }
    public void putNewsCollections(int value) {
        stats.put("newsCollections", value);
    }

    public PersonalInfoDTO(User user) {
        this.id = user.getId();
        this.name = user.getNickname();
        this.avatar = user.getProfile();
        this.cover = user.getBgImage();
        this.headline = user.getIntroduction();
        this.gender = user.getGender();
        putFollowers(user.getFollowerNum());
        putFollowing(user.getUserFollowingNum());
        putLikeIssues(user.getIssueFollowingNum());
        putLikeSections(user.getSectionFollowingNum());
    }
}
